home *** CD-ROM | disk | FTP | other *** search
- ;;; -*- Scheme -*-
-
- (declare (usual-integrations))
-
- #|
- Description:
-
- This code tests closing over procedures.
- &make-object and &object-ref are not integrated, so util1 and
- util2 must be closed over them, and therefore export1 and export2
- must be closed.
-
- Usage:
-
- (export1 x y) = (cons x (object-datum y))
- (export2 x y) = (cons (object-datum x) y)
-
- Thus
-
- (export1 x y) = (export2 x y) = (cons x y)
- if x and y are fixnums.
-
- Make sure that you do (gc-flip) twice after running this code,
- to make sure that the gc can handle closures.
-
- |#
-
- (define export1)
- (define export2)
-
- (let ((&make-object (make-primitive-procedure '&MAKE-OBJECT 2))
- (&object-ref (make-primitive-procedure 'SYSTEM-MEMORY-REF 2)))
-
- (define (util1 x)
- (&make-object #x1a
- (&object-ref x 0)))
-
- (define (util2 x)
- (util1 (make-cell x)))
-
- (set! export1
- (lambda (x y)
- (cons x (util2 y))))
-
- (set! export2
- (lambda (x y)
- (cons (util2 x) y))))